package com.wancaijinfu.parse;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.wancaijinfu.javabean.Debt;
import com.wancaijinfu.javabean.PageData;

public class DebtListParse  extends PostParse{

	
	@Override
	public Object parseSuccess(JSONObject object) throws JSONException {
		PageData data = new PageData();
		if (object.has("lastPage"))
			data.isLast = object.getBoolean("lastPage");
		JSONArray borrowlist = object.getJSONArray("list");
		List<Debt> list = new ArrayList<Debt>();
		for (int i = 0; i < borrowlist.length(); i++) {
			JSONObject newObj = borrowlist.getJSONObject(i);
			Debt item = new Debt();
			item.id = newObj.getInt("id");
			item.name =  newObj.getString("b_name");
			item.status =  newObj.getInt("status");
			item.user_name = newObj.getString("su_user_name");
			item.discount = newObj.getDouble("discount");
			item.money = newObj.getDouble("money");	
			item.interest = newObj.getDouble("interest");
			item.time_limit = newObj.getInt("time_limit");
			
			item.is_day = newObj.getInt("is_day");
			
			item.apr = newObj.getDouble("apr");
			
			list.add(item);
		}
		data.datas = list;
		return data;
	}
	
	

}
